import visitMonthPlanModel from './model/visitMonthPlanModel'; 

class TestError{
     constructor(){}

    async test_1(){
        //把2018年的计划全部都加上年份
        let dataArr=await visitMonthPlanModel.distinct('month',{})
        //let data=await visitMonthPlanModel.find({month:'Invalid date'})
        //console.log(dataArr,'<============')
        // for (let index = 0; index < dataArr.length; index++) {
        //     let ele = dataArr[index];
        //     //console.log(ele,'????',index)
        //     if(index!=10){
        //         continue;
        //     }
        //     let data=await visitMonthPlanModel.find({month:ele}).sort({planDate:1});
        //     data.map(it=>{
        //        // console.log(it.year)
        //         console.log(it.month,'<<<<month????',it.planDate,'<<<<<date',it.year,'<<<<year',ele,'<<<<month,index>>>',index)
               
               
        //     })
        // }

        // let data=await visitMonthPlanModel.find({month:'01',year:{$ne:'2019'}}).sort({planDate:1}).limit(100);
        // console.log(data,'data_data_data_data_')
        let idArr=await visitMonthPlanModel.distinct('_id',{month:'01',year:{$ne:'2019'}});
        console.log(idArr.length,'data_data_data_data_')

        // let b=await visitMonthPlanModel.updateMany({_id:{$in:idArr}},{year:'2019'},{upsert:true});
        // console.log(b,'????????>>>>>>>>>')
        for (let index = 0; index < idArr.length; index++) {
            let id = idArr[index];
            // let b=await visitMonthPlanModel.update({_id:id},{year:'2019'},{upsert:true});
            // console.log(b,'????????',id,'>>>>>>>>>',index)
            let data2=await visitMonthPlanModel.findById({_id:id});
            console.log(data2.month,'<<<<<<<<<<',data2.year,'<<<<<<<<',index)
        }
        

        
    }
    







}
let testError=new TestError();
export default testError;


